<template>
	<view class="new_page ligth_page">
		<view class="main">
			<view class="search_wrap">
				<uni-search-bar class="uni-mt-0" radius="100" placeholder="请输入订单编号和电话号码" clearButton="auto" cancelButton="none"
					@confirm="search" />
			</view>
			
			<!-- tag -->
			<view class="tag_wrap">
				<view class="tag_item" v-for="(item,index) in tagList" :key="index" @click="indexChange(index)"
					:class="{'active':activeIndex==index}">
					<text>{{item}}</text>
				</view>
			</view>

			<!-- 表单 -->
			<view class="list_wrap">
				<!-- <swiper :indicator-dots="false" :autoplay="false" :interval="4000"
					:duration="500" @change="handleChange" 	:current="activeIndex" style="height: 100%"> -->
					<view v-for="(item,index) in tagList" :key="index">
						<!-- <swiper-item  style="overflow: auto"> -->
							<view class="swiper-item" v-if="activeIndex==index">
								<view class="item_content">
									<view class="row title_wrap">
										<view class="title row_item" v-for="(title,i) in titleList" :key="i">
											<text>{{title}}</text>
										</view>
									</view>
									<template v-if="orderList[index]&&orderList[index].length>0">
										<view class="row"  v-for="(order,i) in orderList[index]" :key="i">
											<view class="row_item no-wrap">
												{{order.orderId}}
											</view>
											<view class="row_item">
												<view class="user_info">
													<view>
														{{order.nickName}}
													</view>
													<text>{{order.phoneNumber}}</text>
												</view>
												
											</view>
											<view class="row_item">
												{{order.statusname}}
											</view>
											<view class="row_item">
												<text class="uni-primary" @click="goToPage('/pagesA/orderDetail/orderDetail?id='+order.couponId)">详情</text>
												<text class="uni-primary ml" v-if="order.orderState=='A'"  @click="goToPage('/pagesA/orderDetailHX/orderDetailHX')">核销</text>
											</view>
										</view>
										
									</template>
									<template v-else>
										<empty></empty>
									</template>
									
								</view>
							</view>
						<!-- </swiper-item> -->
					</view>
				<!-- </swiper> -->
			</view>
		</view>
	</view>
</template>

<script>
	import { orderslist,orderhx } from '@/request/api.js'
	import { toast,useRouter } from '@/request/utils.js'
	export default {
		data() {
			return {
				activeIndex: 0,
				tagList: [
					'全部',
					'已支付',
					'已使用',
					'退款中',
					'已退款'
				],
				titleList: [
					'订单编号',
					'用户',
					'订单状态',
					'操作'
				],
				arr:[
					'',
					'A',
					'V',
					'P',
					'R'
				],
				orderList: [
					[],[],[],[],[]
				]
			}
		},
		onLoad() {
			this.orderslist()
		},
		methods: {
			async search(e) {
				let name = e.value
				let arr = this.arr
				let a =this.activeIndex
				let status = arr[a]
				let res = await orderslist({orderStatus:status,nums:name})
				if(res.code==200){
					this.orderList.splice(this.activeIndex,1,res.data)
				}
			},
			indexChange(e){
				this.activeIndex = e
				let arr = this.arr
				this.orderslist(arr[e]);
			},
			handleChange(e){
				this.activeIndex = e.detail.current;
			},
			async orderslist(status){
				console.log(status)
				let res = await orderslist({orderStatus:status})
				if(res.code==200){
					this.orderList.splice(this.activeIndex,1,res.data)
				}
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.new_page {
		.main {
			display: flex;
			flex-direction: column;
			height: 100%;
		}
	}
	
	.search_wrap {
		background-color: #2C65BB;
	}

	.tag_wrap {
		display: flex;
		justify-content: space-between;
		align-items: center;
		// position: sticky;
		// top: 0;

		.tag_item {
			position: relative;
			font-size: 25rpx;
			color: $text-grey;
			padding: 6rpx 20rpx;
			margin: 30rpx 0;

			&.active {
				color: $uni-primary;
				font-size: 29rpx;

				&::after {
					content: "";
					position: absolute;
					left: 0;
					right: 0;
					bottom: -4rpx;
					margin: auto;
					width: 70%;
					height: 2px;
					background-color: $uni-primary;
				}
			}
		}
	}
	.list_wrap {
		flex: 1;
		.item_content {
			width: 95%;
			margin: auto;
			.title_wrap {
				background-color: #D8D8D8 !important;
				border-radius: 7rpx 7rpx 0 0;
				font-size: 25rpx;
				.row_item:nth-child(n+2) {
					border-left: 1px solid #fff;
				}
			}
			.row {
				display: flex;
				justify-content: space-between;
				align-items: center;
				background-color: #e9e9e9;
			}
			
			.row:nth-child(2n){
				background-color: #fff;
			}
			.row_item {
				flex: 1;
				padding: 20rpx 0;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 22rpx;
				text-align: center;
				.user_info {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
				}
				.ml {
					margin-left: 10rpx;
				}
			}
		}
	}

</style>